package com.aforce3.trailertracer;

import java.awt.Image;
import java.util.ArrayList;
import java.util.List;

/** FrameServer is responsible for hosting the frames to the display and renderers **/
public class FrameServer
{
	List<Frame> frames = new ArrayList<Frame>();
	int nextJob = 0;
	
	public FrameServer(List<Frame> frames)
	{
		this.frames = frames;
	}
	
	public FrameServer(Frame... frames)
	{
		for(Frame f : frames) this.frames.add(f);
	}
	
	public Image getFrame(int id)
	{
		return frames.get(id).getImage();
	}
	
	public int getFrameCount()
	{
		return frames.size();
	}
	
	public Frame getJob()
	{
		Frame job = frames.get(nextJob);
		nextJob++;
		if(nextJob >= frames.size()) nextJob = 0;
		return job;
	}
	
}
